<?php
namespace Apps\Front\Controllers;
use Apps\Front\Controllers\ControllerBase;
use Apps\Model\Userquestion;
use Phalcon\Filter as Filter;

class UserController extends ControllerBase{

    public function forgotpwdAction(){
       
    }
    public function resetphoneAction(){
       
    }

    public function userquestionAction(){
       
    }
  
    public function subquestionAction(){
    	$this->view->disable();
    	//过滤空格
    	$filter = new Filter();
    	$msg=$this->request->getPost('msg','string');
    	$msg = $filter->sanitize($msg, "trim");

    	if(empty($msg)){
        	$this->jump('User/userquestion','提出的问题不能为空');
            return;
        }

    	//将验证码转化成小写判断验证码是否正确
        $code=$this->request->getPost('code','string');
        $code=strtolower($code);
        if(md5($code)!=$this->session->get('code')){
        	$this->jump('User/userquestion','验证码错误');
            return;
        } 
        
        //获取用户的ID
        $user_id=$this->session->get('operator')->id; 
        //将数据插入数据表
        $map = new Userquestion();  
        $map -> user_id=$user_id;
        $map -> msg=$msg;
        if($map->save()){

        	$this->jump('User/userquestion','问题已经提交');
        }

    }
   
}
?>